package com.ybl.store.mp.controller;

import com.ybl.store.backend.dao.entity.customer.CustomerProductDO;
import com.ybl.store.backend.dto.resp.user.customer.CustomerProductNumberDTO;
import com.ybl.store.backend.dto.resp.user.customer.CustomerVoucherNumberDTO;
import com.ybl.store.common.convention.result.Result;
import com.ybl.store.common.convention.result.Results;
import com.ybl.store.common.entity.ListRespDTO;
import com.ybl.store.mp.service.MpService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequiredArgsConstructor
@RequestMapping("mp")
public class MpController {

    private final MpService mpService;

    @GetMapping("/login")
    public Result<String> login(@RequestParam String code) {
        return Results.success(mpService.login(code));
    }

    @PostMapping("/register")
    public Result<String> register(@RequestParam String code, @RequestParam String phone) {
        return Results.success(mpService.register(code, phone));
    }

    @GetMapping("/product")
    public Result<ListRespDTO<CustomerProductNumberDTO>> listGood(@RequestParam Long id) {
        return Results.success(mpService.listProduct(id));
    }

    @GetMapping("/voucher")
    public Result<ListRespDTO<CustomerVoucherNumberDTO>> listCoupon(@RequestParam Long id) {
        return Results.success(mpService.listVoucher(id));
    }
}
